using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;

namespace Editor.AtlasTools
{
    public class AtlasConfigWrapper :SerializedScriptableObject
    {
        public string atlasName;
        bool isLeft;
        bool isSelected;
        [HideInInspector]
        public List<Texture> textureList;
        public const int row = 6;
        // [ShowInInspector]
        public AtlasSpriteInfo[,] SpriteWrappers;
        public void InitTextures()
        {
            if (textureList != null && textureList.Count > 0)
            {
                int column = Mathf.CeilToInt(textureList.Count * 1f / row * 1f);
                SpriteWrappers = new AtlasSpriteInfo[row, column];
                for (int i = 0; i < row * column; i++)
                {
                    int y = i / row;
                    int x = i % row;

                    if (i < textureList.Count)
                    {
                        var wrapper = new AtlasSpriteInfo
                        {
                            texture = textureList[i],
                            Name = textureList[i].name
                        };
                        SpriteWrappers[x, y] = wrapper;
                    }
                    if (i == textureList.Count - 1 || i == row * column - 1)
                    {
                        Debug.Log("设置完毕:" + atlasName + "  " + i + "  ");
                        break;
                    }
                }
            }
            else
            {
                SpriteWrappers = new AtlasSpriteInfo[1, 1]
                {
                    { null }
                };
                Debug.Log("设置完毕:" + atlasName + "0");
            }
        }
    }
}